package boundary;

import java.awt.*;
import java.awt.event.*;

import javax.swing.*;   

/**
 * The Class HowMany.
 */
public class HowMany extends JPanel implements ActionListener{

	private static final long serialVersionUID = 2L;
	private JFrame frame;
	private JLabel show;
	private JPanel panel=new JPanel();
	private JButton twop=new JButton("2");
	private JButton threep=new JButton("3");
	private JButton fourp=new JButton("4");
	private JButton fivep=new JButton("5");
	private JButton sixp=new JButton("6");
	private boolean ischinese;
	
	
	public HowMany(JFrame frame,boolean ischinese){
		
		this.frame=frame;
		this.ischinese=ischinese;
		 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		 frame.setLocationRelativeTo(null);
		 frame.setTitle("SELECT NUMBER OF PLAYER");
		 frame.setResizable(false);
		 frame.setVisible(true);
		 
		 if(ischinese)show=new JLabel("many Chinese");
		 else{
			 show=new JLabel("How Many Player?");
		 }
		 twop.addActionListener(this);
		 threep.addActionListener(this);
		 fourp.addActionListener(this);
		 fivep.addActionListener(this);
		 sixp.addActionListener(this);
		 panel.add(show);
		 panel.add(twop);
		 panel.add(threep);
		 panel.add(fourp);
		 panel.add(fivep);
		 panel.add(sixp);
		 frame.setContentPane(panel);
		 frame.validate();
		 frame.repaint();
	}
	
	public void actionPerformed(ActionEvent action) {
		JButton selected = (JButton)action.getSource();
		if(selected==twop){
			new SelectRole(frame,ischinese,2);
		}else if(selected==threep){
			new SelectRole(frame,ischinese,3);
		}else if(selected==fourp){
			new SelectRole(frame,ischinese,4);
		}else if(selected==fivep){
			new SelectRole(frame,ischinese,5);
		}else if(selected==sixp){
			new SelectRole(frame,ischinese,6);
		}
	}
	public void paint(Graphics g){
		super.paint(g);
	}
}
